<?php
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
?>
<ul id="popularProduct">
    <?php
    foreach ($data as $item) {
        $image = field_file_load($item->fid);
        $image_path = base_path() . imagecache_create_path('product_list', $image['filepath']);
        $link = url('node/' . $item->nid);
        $price = uc_price(array('price' => $item->uc_products_sell_price, 'qty' => 1), array('revision' => 'formatted'));

        $voate_average = votingapi_select_results(array(
                    'content_id' => $item->nid,
                    'function' => 'average'
                ));

        $vote_html = theme_fivestar_static($voate_average[0]['value']);
    ?>
        <li>
            <div class="productItem">
                <a href="<?php print $link ?>"><img src="<?php print $image_path ?>" /></a>
                <span class="vote"><?php print $vote_html; ?></span>
                <span class="title"><a href="<?php print $link ?>"><?php print substr($item->node_title, 0, 20); ?></a></span>
                <span class="price"><?php print $price; ?></span>
            </div>
        </li>
    <?php } ?>
</ul>